﻿using System.Windows;
using System.Windows.Browser;
using QDP.Platform.Silverlight;
using QDP.Platform.Services;

namespace Apps.Common
{
    public class Logout : PartElement
    {
        public override void Show()
        {
            var MessageContract = new MessageContract()
            {
                Message = "确定注销当前账号？",
                Title = "提示",
                Button = MessageBoxButton.OKCancel
            };
            if (this.ShowMessage(MessageContract) == MessageBoxResult.OK)
            {
                try
                {
                    dynamic dy = Q.DataManager.GetUserData();
                    HtmlPage.Window.Eval("try{userlogout('" + dy.userID + "');}catch(e){alert('" + dy.UserName + "注销失败！');}");
                }
                catch
                {
                    HtmlPage.Window.Eval("try{logoutall();}catch(e){alert('注销失败！');}");
                }
            }
        }
    }
}
